//商品主页

module.exports = (req, res) => {
    // 获取cookie传过来的token进行验证
    let arr = req.headers.cookie.split(';');
    let itemObj = {};
    arr.forEach(item => {
        let itemArr = item.trim().split("=");
        itemObj[itemArr[0]] = itemArr[1];
    });
    let token = itemObj.fskl + "." + itemObj.sswr + "." + itemObj.ttnk;
    // console.log(token);
    // 获取用户id
    jwt.verify(token, 't-o_ken', function (err, decoded) {
        // console.log("err", err);
        if (decoded) {
            model.Product.find({
                userId:decoded.data
            }).then(result => {
                // console.log(result);
                res.send({
                    code: "200",
                    status:"405",
                    productArr:result
                })
            })
        } else {
            res.send({
                code: "200",
                status:"406",
                msg:err
            })
        }
    });

}